home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
REXP_SRC
/
XCMDGLUE.C
< prev
Wrap
Text File
|
1989-09-18
|
12KB
|
389 lines
/*
XCmdGlue.inc.c Definitions for calling all standard
HyperCard callback routines from C.
⌐Apple Computer, Inc. 1987
All Rights Reserved.
*/
#include <MacTypes.h>
#include "HyperXCmd.h"
pascal void SendCardMessage(paramPtr,msg)
XCmdBlockPtr paramPtr; StringPtr msg;
/* Send a HyperCard message (a command with arguments) to the current card.
msg is a pointer to a Pascal format string. */
{
paramPtr->inArgs[0] = (long)msg;
paramPtr->request = xreqSendCardMessage;
DoJsr(paramPtr);
}
pascal Handle EvalExpr(paramPtr,expr)
XCmdBlockPtr paramPtr; StringPtr expr;
/* Evaluate a HyperCard expression and return the answer. The answer is
a handle to a zero-terminated string. */
{
paramPtr->inArgs[0] = (long)expr;
paramPtr->request = xreqEvalExpr;
DoJsr(paramPtr);
return (Handle)paramPtr->outArgs[0];
}
pascal long StringLength(paramPtr,strPtr)
XCmdBlockPtr paramPtr; StringPtr strPtr;
/* Count the characters from where strPtr points until the next zero byte.
Does not count the zero itself. strPtr must be a zero-terminated string. */
{
paramPtr->inArgs[0] = (long)strPtr;
paramPtr->request = xreqStringLength;
DoJsr(paramPtr);
return (long)paramPtr->outArgs[0];
}
pascal Ptr StringMatch(paramPtr,pattern,target)
XCmdBlockPtr paramPtr; StringPtr pattern; Ptr target;
/* Perform case-insensitive match looking for pattern anywhere in
target, returning a pointer to first character of the first match,
in target or NIL if no match found. pattern is a Pascal string,
and target is a zero-terminated string. */
{
paramPtr->inArgs[0] = (long)pattern;
paramPtr->inArgs[1] = (long)target;
paramPtr->request = xreqStringMatch;
DoJsr(paramPtr);
return (Ptr)paramPtr->outArgs[0];
}
pascal void SendHCMessage(paramPtr,msg)
XCmdBlockPtr paramPtr; StringPtr msg;
/* Send a HyperCard message (a command with arguments) to HyperCard.
msg is a pointer to a Pascal format string. */
{
paramPtr->inArgs[0] = (long)msg;
paramPtr->request = xreqSendHCMessage;
DoJsr(paramPtr);
}
pascal void ZeroBytes(paramPtr,dstPtr,longCount)
XCmdBlockPtr paramPtr; Ptr dstPtr; long longCount;
/* Write zeros into memory starting at destPtr and going for longCount
number of bytes. */
{
paramPtr->inArgs[0] = (long)dstPtr;
paramPtr->inArgs[1] = longCount;
paramPtr->request = xreqZeroBytes;
DoJsr(paramPtr);
}
pascal Handle PasToZero(paramPtr,pasStr)
XCmdBlockPtr paramPtr; StringPtr pasStr;
/* Convert a Pascal string to a zero-terminated string. Returns a handle
to a new zero-terminated string. The caller must dispose the handle.
You'll need to do this for any result or argument you send from
your XCMD to HyperTalk. */
{
paramPtr->inArgs[0] = (long)pasStr;
paramPtr->request = xreqPasToZero;
DoJsr(paramPtr);
return (Handle)paramPtr->outArgs[0];
}
pascal void ZeroToPas(paramPtr,zeroStr,pasStr)
XCmdBlockPtr paramPtr; char *zeroStr; StringPtr pasStr;
/* Fill the Pascal string with the contents of the zero-terminated
string. You create the Pascal string and pass it in as a VAR
parameter. Useful for converting the arguments of any XCMD to
Pascal strings. */
{
paramPtr->inArgs[0] = (long)zeroStr;
paramPtr->inArgs[1] = (long)pasStr;
paramPtr->request = xreqZeroToPas;
DoJsr(paramPtr);
}
pascal long StrToLong(paramPtr,strPtr)
XCmdBlockPtr paramPtr; Str31 * strPtr;
/* Convert a string of ASCII decimal digits to an unsigned long integer. */
{
paramPtr->inArgs[0] = (long)strPtr;
paramPtr->request = xreqStrToLong;
DoJsr(paramPtr);
return (long)paramPtr->outArgs[0];
}
pascal long StrToNum(paramPtr,str)
XCmdBlockPtr paramPtr; Str31 * str;
/* Convert a string of ASCII decimal digits to a signed long integer.
Negative sign is allowed. */
{
paramPtr->inArgs[0] = (long)str;
paramPtr->request = xreqStrToNum;
DoJsr(paramPtr);
return paramPtr->outArgs[0];
}
pascal Boolean StrToBool(paramPtr,str)
XCmdBlockPtr paramPtr; Str31 * str;
/* Convert the Pascal strings 'true' and 'false' to booleans. */
{
paramPtr->inArgs[0] = (long)str;
paramPtr->request = xreqStrToBool;
DoJsr(paramPtr);
return (Boolean)paramPtr->outArgs[0];
}
pascal void StrToExt(paramPtr,str,myext)
XCmdBlockPtr paramPtr; Str31 * str; extended * myext;
/* Convert a string of ASCII decimal digits to an extended long integer.
Instead of returning a new extended, as Pascal does, it expects you
to create myext and pass it in to be filled. */
{
paramPtr->inArgs[0] = (long)str;
paramPtr->inArgs[1] = (long)myext;
paramPtr->request = xreqStrToExt;
DoJsr(paramPtr);
}
pascal void LongToStr(paramPtr,posNum,mystr)
XCmdBlockPtr paramPtr; long posNum; Str31 * mystr;
/* Convert an unsigned long integer to a Pascal string. Instead of
returning a new string, as Pascal does, it expects you to
create mystr and pass it in to be filled. */
{
paramPtr->inArgs[0] = (long)posNum;
paramPtr->inArgs[1] = (long)mystr;
paramPtr->request = xreqLongToStr;
DoJsr(paramPtr);
}
pascal void NumToStr(paramPtr,num,mystr)
XCmdBlockPtr paramPtr; long num; Str31 * mystr;
/* Convert a signed long integer to a Pascal string. Instead of
returning a new string, as Pascal does, it expects you to
create mystr and pass it in to be filled. */
{
paramPtr->inArgs[0] = num;
paramPtr->inArgs[1] = (long)mystr;
paramPtr->request = xreqNumToStr;
DoJsr(paramPtr);
}
pascal void NumToHex(paramPtr,num,nDigits,mystr)
XCmdBlockPtr paramPtr; long num;
short nDigits; Str31 * mystr;
/* Convert an unsigned long integer to a hexadecimal number and put it
into a Pascal string. Instead of returning a new string, as
Pascal does, it expects you to create mystr and pass it in to be filled. */
{
paramPtr->inArgs[0] = num;
paramPtr->inArgs[1] = nDigits;
paramPtr->inArgs[2] = (long)mystr;
paramPtr->request = xreqNumToHex;
DoJsr(paramPtr);
}
pascal void BoolToStr(paramPtr,bool,mystr)
XCmdBlockPtr paramPtr; Boolean bool; Str31 * mystr;
/* Convert a boolean to 'true' or 'false'. Instead of returning
a new string, as Pascal does, it expects you to create mystr
and pass it in to be filled. */
{
paramPtr->inArgs[0] = (long)bool;
paramPtr->inArgs[1] = (long)mystr;
paramPtr->request = xreqBoolToStr;
DoJsr(paramPtr);
}
pascal void ExtToStr(paramPtr,myext,mystr)
XCmdBlockPtr paramPtr; extended * myext; Str31 * mystr;
/* Convert an extended long integer to decimal digits in a string.
Instead of returning a new string, as Pascal does, it expects
you to create mystr and pass it in to be filled. */
{
paramPtr->inArgs[0] = (long)myext;
paramPtr->inArgs[1] = (long)mystr;
paramPtr->request = xreqExtToStr;
DoJsr(paramPtr);
}
pascal Handle GetGlobal(paramPtr,globName)
XCmdBlockPtr paramPtr; StringPtr globName;
/* Return a handle to a zero-terminated string containing the value of
the specified HyperTalk global variable. */
{
paramPtr->inArgs[0] = (long)globName;
paramPtr->request = xreqGetGlobal;
DoJsr(paramPtr);
return (Handle)paramPtr->outArgs[0];
}
pascal void SetGlobal(paramPtr,globName,globValue)
XCmdBlockPtr paramPtr; StringPtr globName; Handle globValue;
/* Set the value of the specified HyperTalk global variable to be
the zero-terminated string in globValue. The contents of the
Handle are copied, so you must still dispose it afterwards. */
{
paramPtr->inArgs[0] = (long)globName;
paramPtr->inArgs[1] = (long)globValue;
paramPtr->request = xreqSetGlobal;
DoJsr(paramPtr);
}
pascal Handle GetFieldByName(paramPtr,cardFieldFlag,fieldName)
XCmdBlockPtr paramPtr; Boolean cardFieldFlag;
StringPtr fieldName;
/* Return a handle to a zero-terminated string containing the value of
field fieldName on the current card. You must dispose the handle. */
{
paramPtr->inArgs[0] = (long)cardFieldFlag;
paramPtr->inArgs[1] = (long)fieldName;
paramPtr->request = xreqGetFieldByName;
DoJsr(paramPtr);
return (Handle)paramPtr->outArgs[0];
}
pascal Handle GetFieldByNum(paramPtr,cardFieldFlag,fieldNum)
XCmdBlockPtr paramPtr; Boolean cardFieldFlag;
short fieldNum;
/* Return a handle to a zero-terminated string containing the value of
field fieldNum on the current card. You must dispose the handle. */
{
paramPtr->inArgs[0] = (long)cardFieldFlag;
paramPtr->inArgs[1] = fieldNum;
paramPtr->request = xreqGetFieldByNum;
DoJsr(paramPtr);
return (Handle)paramPtr->outArgs[0];
}
pascal Handle GetFieldByID(paramPtr,cardFieldFlag,fieldID)
XCmdBlockPtr paramPtr; Boolean cardFieldFlag;
short fieldID;
/* Return a handle to a zero-terminated string containing the value of
the field whise ID is fieldID. You must dispose the handle. */
{
paramPtr->inArgs[0] = (long)cardFieldFlag;
paramPtr->inArgs[1] = fieldID;
paramPtr->request = xreqGetFieldByID;
DoJsr(paramPtr);
return (Handle)paramPtr->outArgs[0];
}
pascal void SetFieldByName(paramPtr,cardFieldFlag,fieldName,fieldVal)
XCmdBlockPtr paramPtr; Boolean cardFieldFlag;
StringPtr fieldName; Handle fieldVal;
/* Set the value of field fieldName to be the zero-terminated string
in fieldVal. The contents of the Handle are copied, so you must
still dispose it afterwards. */
{
paramPtr->inArgs[0] = (long)cardFieldFlag;
paramPtr->inArgs[1] = (long)fieldName;
paramPtr->inArgs[2] = (long)fieldVal;
paramPtr->request = xreqSetFieldByName;
DoJsr(paramPtr);
}
pascal void SetFieldByNum(paramPtr,cardFieldFlag,fieldNum,fieldVal)
XCmdBlockPtr paramPtr; Boolean cardFieldFlag;
short fieldNum; Handle fieldVal;
/* Set the value of field fieldNum to be the zero-terminated string
in fieldVal. The contents of the Handle are copied, so you must
still dispose it afterwards. */
{
paramPtr->inArgs[0] = (long)cardFieldFlag;
paramPtr->inArgs[1] = fieldNum;
paramPtr->inArgs[2] = (long)fieldVal;
paramPtr->request = xreqSetFieldByNum;
DoJsr(paramPtr);
}
pascal void SetFieldByID(paramPtr,cardFieldFlag,fieldID,fieldVal)
XCmdBlockPtr paramPtr; Boolean cardFieldFlag;
short fieldID; Handle fieldVal;
/* Set the value of the field whose ID is fieldID to be the zero-
terminated string in fieldVal. The contents of the Handle are
copied, so you must still dispose it afterwards. */
{
paramPtr->inArgs[0] = (long)cardFieldFlag;
paramPtr->inArgs[1] = fieldID;
paramPtr->inArgs[2] = (long)fieldVal;
paramPtr->request = xreqSetFieldByID;
DoJsr(paramPtr);
}
pascal Boolean StringEqual(paramPtr,str1,str2)
XCmdBlockPtr paramPtr; Str31 * str1; Str31 * str2;
/* Return true if the two strings have the same characters.
Case insensitive compare of the strings. */
{
paramPtr->inArgs[0] = (long)str1;
paramPtr->inArgs[1] = (long)str2;
paramPtr->request = xreqStringEqual;
DoJsr(paramPtr);
return (Boolean)paramPtr->outArgs[0];
}
pascal void ReturnToPas(paramPtr,zeroStr,pasStr)
XCmdBlockPtr paramPtr; Ptr zeroStr; StringPtr pasStr;
/* zeroStr points into a zero-terminated string. Collect the
characters from there to the next carriage Return and return
them in the Pascal string pasStr. If a Return is not found,
collect chars until the end of the string. */
{
paramPtr->inArgs[0] = (long)zeroStr;
paramPtr->inArgs[1] = (long)pasStr;
paramPtr->request = xreqReturnToPas;
DoJsr(paramPtr);
}
pascal void ScanToReturn(paramPtr,scanHndl)
XCmdBlockPtr paramPtr; Ptr * scanHndl;
/* Move the pointer scanPtr along a zero-terminated
string until it points at a Return character
or a zero byte. */
{
paramPtr->inArgs[0] = (long)scanHndl;
paramPtr->request = xreqScanToReturn;
DoJsr(paramPtr);
}
pascal void ScanToZero(paramPtr,scanHndl)
XCmdBlockPtr paramPtr; Ptr * scanHndl;
/* Move the pointer scanPtr along a zero-terminated
string until it points at a zero byte. */
{
paramPtr->inArgs[0] = (long)scanHndl;
paramPtr->request = xreqScanToZero;
DoJsr(paramPtr);
}
pascal void DoJsr(paramPtr)
XCmdBlockPtr paramPtr;
{
CallPascal(paramPtr->entryPoint);
}